package avicit.bdp.dcs.stream.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
import java.util.Objects;


/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2020-10-16
 * @类说明：MsgTemplateDto
 * @修改记录：
 * @注意事项：
 * @主要功能：消息模板Entity
 */
@ApiModel(value = "TemplateDto", description = "bdp_dcs_msg_template")
@Table(name = "bdp_dcs_msg_template")
public class MsgTemplateDto extends BaseDTO {
    private static final long serialVersionUID = 1L;

    // 主键
    @Id
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "id")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    /**
     * 数据项目Id
     */
    @LogField
    @ApiModelProperty(value = "数据项目Id")
    @FieldRemark(column = "project_id", field = "projectId", name = "数据项目Id")
    @Column(name = "project_id")
    private String projectId;

    // 设备ID
    @LogField
    @ApiModelProperty(value = "设备ID，唯一")
    @FieldRemark(column = "device_id", field = "device_id", name = "设备ID")
    @Column(name = "device_id")
    private String deviceId;

    // 设备名称
    @LogField
    @ApiModelProperty(value = "设备名称")
    @FieldRemark(column = "device_name", field = "device_name", name = "设备名称")
    @Column(name = "device_name")
    private String deviceName;

    // 设备描述
    @LogField
    @ApiModelProperty(value = "设备描述")
    @FieldRemark(column = "remark", field = "remark", name = "设备描述")
    @Column(name = "remark")
    private String remark;

    // 设备类型ID
    @LogField
    @ApiModelProperty(value = "设备类型ID")
    @FieldRemark(column = "device_type_id", field = "device_type_id", name = "设备类型ID")
    @Column(name = "device_type_id")
    private String deviceTypeId;

    // 设备类型名称
    @LogField
    @ApiModelProperty(value = "设备类型名称")
    @FieldRemark(column = "device_type_name", field = "device_type_name", name = "设备类型名称")
    @Column(name = "device_type_name")
    private String deviceTypeName;

    // 区域ID
    @LogField
    @ApiModelProperty(value = "区域ID")
    @FieldRemark(column = "area_id", field = "area_id", name = "区域ID")
    @Column(name = "area_id")
    private String areaId;

    // 区域名称
    @LogField
    @ApiModelProperty(value = "区域名称")
    @FieldRemark(column = "area_name", field = "area_name", name = "区域名称")
    @Column(name = "area_name")
    private String areaName;

    // 资产ID
    @LogField
    @ApiModelProperty(value = "资产ID")
    @FieldRemark(column = "asset_id", field = "asset_id", name = "资产ID")
    @Column(name = "asset_id")
    private String assetId;

    // 资产名称
    @LogField
    @ApiModelProperty(value = "资产名称")
    @FieldRemark(column = "asset_name", field = "asset_name", name = "资产名称")
    @Column(name = "asset_name")
    private String assetName;

    // 用户ID
    @LogField
    @ApiModelProperty(value = "用户ID")
    @FieldRemark(column = "customer_id", field = "customer_id", name = "用户ID")
    @Column(name = "customer_id")
    private String customerId;

    // 用户名称
    @LogField
    @ApiModelProperty(value = "用户名称")
    @FieldRemark(column = "customer_name", field = "customer_name", name = "用户名称")
    @Column(name = "customer_name")
    private String customerName;

    // 消息模板参数
    @LogField
    @ApiModelProperty(value = "消息模板参数")
    @FieldRemark(column = "paras", field = "paras", name = "消息模板参数")
    @Column(name = "paras")
    private String paras;

    // 组织机构代码
    @ApiModelProperty(value = "组织机构代码")
    @FieldRemark(column = "org_identity", field = "orgIdentity", name = "组织机构代码")
    @Column(name = "org_identity")
    private String orgIdentity;

    // 密级
    @ApiModelProperty(value = "密级")
    @FieldRemark(column = "secret_level", field = "secretLevel", name = "密级")
    @Column(name = "secret_level")
    private String secretLevel;

    // 上传模板文件，模板信息
    @ApiModelProperty(value = "模板文件上传使用")
    @Transient
    private MultipartFile file;

    // 上传模板文件，返回解析结果
    @ApiModelProperty(value = "解析模板文件时返回")
    @Transient
    private List<MeasureParaDto> measureParaDtoList;

    public String getId() {
        return id;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public String getRemark() {
        return remark;
    }

    public String getDeviceTypeId() {
        return deviceTypeId;
    }

    public String getDeviceTypeName() {
        return deviceTypeName;
    }

    public String getAreaId() {
        return areaId;
    }

    public String getAreaName() {
        return areaName;
    }

    public String getAssetId() {
        return assetId;
    }

    public String getAssetName() {
        return assetName;
    }

    public String getCustomerId() {
        return customerId;
    }

    public String getCustomerName() {
        return customerName;
    }

    public String getParas() {
        return paras;
    }

    @Override
    public String getOrgIdentity() {
        return orgIdentity;
    }

    @Override
    public String getSecretLevel() {
        return secretLevel;
    }

    public MultipartFile getFile() {
        return file;
    }

    public List<MeasureParaDto> getMeasureParaDtoList() {
        return measureParaDtoList;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public void setDeviceTypeId(String deviceTypeId) {
        this.deviceTypeId = deviceTypeId;
    }

    public void setDeviceTypeName(String deviceTypeName) {
        this.deviceTypeName = deviceTypeName;
    }

    public void setAreaId(String areaId) {
        this.areaId = areaId;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public void setAssetId(String assetId) {
        this.assetId = assetId;
    }

    public void setAssetName(String assetName) {
        this.assetName = assetName;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public void setParas(String paras) {
        this.paras = paras;
    }

    @Override
    public void setOrgIdentity(String orgIdentity) {
        this.orgIdentity = orgIdentity;
    }

    @Override
    public void setSecretLevel(String secretLevel) {
        this.secretLevel = secretLevel;
    }

    public void setFile(MultipartFile file) {
        this.file = file;
    }

    public void setMeasureParaDtoList(List<MeasureParaDto> measureParaDtoList) {
        this.measureParaDtoList = measureParaDtoList;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    /**
     * 覆写equals，保证HashSet中值不重复
     * @param obj
     * @return
     */
    @Override
    public boolean equals(Object obj) {
        if(!(obj instanceof MsgTemplateDto)) {
            return false;
        }

        MsgTemplateDto msgTemplateDto = (MsgTemplateDto) obj;
        if (this == msgTemplateDto) {
            return true;
        }

        // 消息模板唯一标识是templateId，模板名称可以重复
        if (msgTemplateDto.getDeviceId().equals(this.getDeviceId())) {
            return true;
        }

        return false;
    }

    /**
     * 覆写hashCode
     * @return
     */
    @Override
    public int hashCode() {
        return Objects.hash(this.getDeviceId());
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "消息模板管理";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "消息模板";
        } else {
            return super.logTitle;
        }
    }

}
